package com.example.springbootdemo.factory.factorymethor;

/**
 * @author ：cici
 * @date ：Created in 2019/3/12 11:06
 */
public class HumanFactory extends AbstractHumanFactory {

    @Override
    public <T extends Human> T createHuman(Class<T> t) {

        //<T extends Human> T 限定T类型继承Human
        Human human = null;
        try {
            human = (T) Class.forName(t.getName()).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (T)human;

    }
}
